package DataStructures;


import java.util.*;

/**
 * Created by msingh on 2014-06-28.
 */
public class LargestNumber {

    //Create an array of size 5 with random numbers
    public List<Integer> createArray(){
        List<Integer> arr = new ArrayList<Integer>();

        for(int i=0;i<100;i+=5){
            arr.add(i);
        }
        return arr;
    }

    public int findLargest(List<Integer> list) {
        int temp = 0;
//        for (int i = 0; i < list.size(); i++) {
            for (int x = 1; x < list.size(); x++) {
                if (list.get(x - 1) < list.get(x)) {

                    temp = list.get(x);
                }
                else{
                    temp = list.get(x-1);
                }
            }
//        }
        return temp;
    }

    public static void main(String[] args){
        LargestNumber arr1 = new LargestNumber();
        System.out.println("CustomArray is : " + arr1.createArray());

        System.out.println("Largest Value in a is : " + arr1.findLargest(arr1.createArray()));

    }

}
